package com.lyy.mybatis.sensitive.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lyy.mybatis.sensitive.annotation.SensitiveField;
import com.lyy.mybatis.sensitive.demo.domain.dto.UserQueryDTO;
import com.lyy.mybatis.sensitive.demo.domain.entity.UserEntity;
import com.lyy.mybatis.sensitive.secret.Secret62;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author lyy 2024/11/26
 */
@Mapper
public interface UserMapper extends BaseMapper<UserEntity> {

    /**
     * 入参为字符串
     */
    @Select("select * from user where mobile=#{mobile}")
    List<UserEntity> listByPhoneParam(@SensitiveField(Secret62.class) @Param("mobile") String mobile);

    /**
     * 入参为对象
     */
    @Select("select * from user where mobile=#{mobile}")
    List<UserEntity> listByPhoneUserDto(UserQueryDTO dto);

}
